package com.yhb.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.yhb.channel.model.IBankCard;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Card implements IBankCard {
    private String id;
    private String userId;
    private String number;
    private String phoneNumber;
    private Type type;
    private String cvv2;
    private String payDay;
    private String billDay;
    private String validation;
    private Date createTime;
    private String positiveImg;
    private Status status;
    private String province;
    private String city;
    private String district;

    private String bankName; // 银行信息
    private String subBankName; // 支行信息
    private Integer isDefaultCard; // 默认结算卡

    @JsonIgnore
    private Integer deleted; // 逻辑删除

    @JsonInclude
    @Override
    public String getBankCardImgUrl() {
        return getPositiveImg();
    }

    @JsonIgnore
    @Override
    public int getCardType() {
        if (this.type == Type.DEBIT) return 0;
        return 1;
    }

    public enum Type {
        CREDIT,
        DEBIT
    }

    public enum Status {
        UNBOUND,
        BOUND
    }
}